package com.zipkinServer.ZipkinServer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
public class ZipkinGoodByeApplication {

	public static void main(String[] args) {
		SpringApplication.run(ZipkinGoodByeApplication.class, args);
	}

	private final static Logger logger = LoggerFactory.getLogger(ZipkinGoodByeApplication.class);
	private final static Logger kibanaLogger = LoggerFactory.getLogger("kibanaLog");

	@Autowired
	private RestTemplate restTemplate;

	@Bean
	public RestTemplate getRestTemplate(){
		return new RestTemplate();
	}

	@RequestMapping("/sayGoodBye")
	public String sayGoodBye() {
		logger.info("----sayGoodBye----");
		kibanaLogger.info("=========kibana:sayGoodBye=========");
		ResponseEntity<String> responseEntity = restTemplate.getForEntity("http://localhost:8999/goodByeToHello?name={1}", String.class, "8988李四");
		return responseEntity.getBody();
	}
	@RequestMapping("/hello")
	public String sayHello2(String name) {
		logger.info("----hello----");
		kibanaLogger.info("=========kibana:hello=========");
		return "hello,"+name;
	}

}
